Module/interface augmentation doesn't preserve import for declaration emit
Chưa có ai nhận issue này.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
🔎 Search Terms
- project references
- module/interface augmentation
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about project references.
⏯ Playground Link
No response
💻 Code
Full reduced test case (contents inlined below): https://github.com/OliverJAsh/ts-project-references-augmentation-bug
package.json:
{
"dependencies": {
"fp-ts": "^2.16.1",
"typescript": "^5.2.2"
}
}
app/tsconfig.json:
{
"compilerOptions": {
"rootDir": "../",
"outDir": "../target",
"composite": true
}
}
app/index.ts:
import * as ReadonlyTuple from 'fp-ts/ReadonlyTuple';
export const Apply = ReadonlyTuple.getApply({ concat: a => a });
demos/tsconfig.json:
{
"compilerOptions": {
"rootDir": "../",
"outDir": "../target"
},
"references": [
{ "path": "../app/tsconfig.json" },
]
}
demos/index.ts:
import { Apply } from "../app/index";
Apply;
🙁 Actual behavior
A module in the "app" project imports the file node_modules/fp-ts/lib/ReadonlyTuple.d.ts. This file uses module and interface augmentation. Excerpt:
export declare const URI = 'ReadonlyTuple'
/**
* @category type lambdas
* @since 2.5.0
*/
export type URI = typeof URI
declare module './HKT' {
interface URItoKind2<E, A> {
readonly [URI]: readonly [A, E]
}
}
When I later try to reference the "app" project from another project ("demos") using project references, I get a type error because the module/interface augmentation is not being applied:
$ yarn run tsc --build --verbose demos/tsconfig.json
yarn run v1.22.19
warning package.json: No license field
$ /Users/oliver/Code/reduced-test-cases/ts-project-references-augmentation-bug/node_modules/.bin/tsc --build --verbose demos/tsconfig.json
[13:49:06] Projects in this build:
* app/tsconfig.json
* demos/tsconfig.json
[13:49:06] Project 'app/tsconfig.json' is out of date because output file 'target/app/tsconfig.tsbuildinfo' does not exist
[13:49:06] Building project '/Users/oliver/Code/reduced-test-cases/ts-project-references-augmentation-bug/app/tsconfig.json'...
[13:49:06] Project 'demos/tsconfig.json' is out of date because output file 'target/demos/index.js' does not exist
[13:49:06] Building project '/Users/oliver/Code/reduced-test-cases/ts-project-references-augmentation-bug/demos/tsconfig.json'...
target/app/index.d.ts:1:63 - error TS2344: Type '"ReadonlyTuple"' does not satisfy the constraint 'keyof URItoKind2<any, any>'.
1 export declare const Apply: import("fp-ts/lib/Apply").Apply2C<"ReadonlyTuple", unknown>;
~~~~~~~~~~~~~~~
Found 1 error.
🙂 Expected behavior
No error. The module/interface augmentation should be applied in the dependant project when it consumes the type declarations of the referenced project.
Additional information about the issue
I am able to workaround the issue by adding an explicit import of fp-ts/ReadonlyTuple in demos/index.ts.
- Ngôn ngữ chính
- Go
- Star
- 111k
- Fork
- 14.4k
- Merge trung bình
- 1 ngày 19 giờ
- Pull request đã merge (30 ngày)
- 117
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/TypeScript
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
microsoft/TypeScript#64322 · 2 bình luận · 1 reaction · 2 người được giao ·
-
Possible Improvement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
microsoft/TypeScript#64278 · 1 bình luận · 1 reaction ·
-
Docs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
microsoft/TypeScript#64118 · 1 bình luận ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
microsoft/TypeScript#64094 ·
-
Docs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
microsoft/TypeScript#63959 · 5 bình luận ·
Tất cả issue của microsoft/TypeScript
Issue tương tự
-
optimization optimization:agents-md-curator
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
githubnext/gh-aw-cao#13143 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
blinklabs-io/bursa#904 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
yanet-platform/ipfw-go#129 ·
-
bug confmap/provider/googlesecretmanagerprovider needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
open-telemetry/opentelemetry-collector-contrib#51273 · 2 bình luận ·
-
bug: AI Gateway client filter lists "Unknown" twice when NULL and literal Unknown clients coexist Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100