-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build better import paths for declaration emit/typeToString from reex…
…ports if possible (#27340) * Build better import paths from reexports if possible, issue error on node_modules import generation * Small refactorings * Add file-by-file cacheing * Minor cleanups * Adjust error message
- Loading branch information
Showing
29 changed files
with
937 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
tests/baselines/reference/declarationEmitCommonJsModuleReferencedType.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
tests/cases/compiler/r/entry.ts(3,14): error TS2742: The inferred type of 'x' cannot be named without a reference to 'foo/node_modules/nested'. This is likely not portable. A type annotation is necessary. | ||
|
||
|
||
==== tests/cases/compiler/r/node_modules/foo/node_modules/nested/index.d.ts (0 errors) ==== | ||
export interface NestedProps {} | ||
==== tests/cases/compiler/r/node_modules/foo/other/index.d.ts (0 errors) ==== | ||
export interface OtherIndexProps {} | ||
==== tests/cases/compiler/r/node_modules/foo/other.d.ts (0 errors) ==== | ||
export interface OtherProps {} | ||
==== tests/cases/compiler/r/node_modules/foo/index.d.ts (0 errors) ==== | ||
import { OtherProps } from "./other"; | ||
import { OtherIndexProps } from "./other/index"; | ||
import { NestedProps } from "nested"; | ||
export interface SomeProps {} | ||
|
||
export function foo(): [SomeProps, OtherProps, OtherIndexProps, NestedProps]; | ||
==== tests/cases/compiler/node_modules/root/index.d.ts (0 errors) ==== | ||
export interface RootProps {} | ||
|
||
export function bar(): RootProps; | ||
==== tests/cases/compiler/r/entry.ts (1 errors) ==== | ||
import { foo } from "foo"; | ||
import { bar } from "root"; | ||
export const x = foo(); | ||
~ | ||
!!! error TS2742: The inferred type of 'x' cannot be named without a reference to 'foo/node_modules/nested'. This is likely not portable. A type annotation is necessary. | ||
export const y = bar(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
tests/baselines/reference/declarationEmitReexportedSymlinkReference.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
//// [tests/cases/compiler/declarationEmitReexportedSymlinkReference.ts] //// | ||
|
||
//// [index.d.ts] | ||
export * from './types'; | ||
//// [types.d.ts] | ||
export declare type A = { | ||
id: string; | ||
}; | ||
export declare type B = { | ||
id: number; | ||
}; | ||
export declare type IdType = A | B; | ||
export declare class MetadataAccessor<T, D extends IdType = IdType> { | ||
readonly key: string; | ||
private constructor(); | ||
toString(): string; | ||
static create<T, D extends IdType = IdType>(key: string): MetadataAccessor<T, D>; | ||
} | ||
//// [package.json] | ||
{ | ||
"name": "@raymondfeng/pkg1", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "dist/index.js", | ||
"typings": "dist/index.d.ts" | ||
} | ||
//// [index.d.ts] | ||
export * from './types'; | ||
//// [types.d.ts] | ||
export * from '@raymondfeng/pkg1'; | ||
//// [package.json] | ||
{ | ||
"name": "@raymondfeng/pkg2", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "dist/index.js", | ||
"typings": "dist/index.d.ts" | ||
} | ||
//// [index.ts] | ||
export * from './keys'; | ||
//// [keys.ts] | ||
import {MetadataAccessor} from "@raymondfeng/pkg2"; | ||
|
||
export const ADMIN = MetadataAccessor.create<boolean>('1'); | ||
|
||
//// [keys.js] | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var pkg2_1 = require("@raymondfeng/pkg2"); | ||
exports.ADMIN = pkg2_1.MetadataAccessor.create('1'); | ||
//// [index.js] | ||
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./keys")); | ||
|
||
|
||
//// [keys.d.ts] | ||
import { MetadataAccessor } from "@raymondfeng/pkg2"; | ||
export declare const ADMIN: MetadataAccessor<boolean, import("@raymondfeng/pkg2").IdType>; | ||
//// [index.d.ts] | ||
export * from './keys'; |
Oops, something went wrong.