-
Notifications
You must be signed in to change notification settings - Fork 12.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Error if type node uses inaccessible type in isolated declarations (#…
- Loading branch information
1 parent
f2aebff
commit 8537bb7
Showing
8 changed files
with
190 additions
and
17 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
49 changes: 49 additions & 0 deletions
49
tests/baselines/reference/transpile/declarationNotInScopeTypes.d.ts
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,49 @@ | ||
//// [variables.ts] //// | ||
const x = ""; | ||
export function one() { | ||
return {} as typeof x; | ||
} | ||
|
||
export function two() { | ||
const y = ""; | ||
return {} as typeof y; | ||
} | ||
|
||
export function three() { | ||
type Z = string; | ||
return {} as Z; | ||
} | ||
//// [variables.d.ts] //// | ||
declare const x = ""; | ||
export declare function one(): typeof x; | ||
export declare function two(): ""; | ||
export declare function three(): string; | ||
export {}; | ||
|
||
|
||
//// [Diagnostics reported] | ||
variables.ts(8,25): error TS9039: Type containing private name 'y' can't be used with --isolatedDeclarations. | ||
variables.ts(13,18): error TS9039: Type containing private name 'Z' can't be used with --isolatedDeclarations. | ||
|
||
|
||
==== variables.ts (2 errors) ==== | ||
const x = ""; | ||
export function one() { | ||
return {} as typeof x; | ||
} | ||
|
||
export function two() { | ||
const y = ""; | ||
return {} as typeof y; | ||
~ | ||
!!! error TS9039: Type containing private name 'y' can't be used with --isolatedDeclarations. | ||
!!! related TS9031 variables.ts:6:17: Add a return type to the function declaration. | ||
} | ||
export function three() { | ||
type Z = string; | ||
return {} as Z; | ||
~ | ||
!!! error TS9039: Type containing private name 'Z' can't be used with --isolatedDeclarations. | ||
!!! related TS9031 variables.ts:11:17: Add a return type to the function declaration. | ||
} |
27 changes: 27 additions & 0 deletions
27
tests/baselines/reference/transpile/declarationNotInScopeTypes.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,27 @@ | ||
//// [variables.ts] //// | ||
const x = ""; | ||
export function one() { | ||
return {} as typeof x; | ||
} | ||
|
||
export function two() { | ||
const y = ""; | ||
return {} as typeof y; | ||
} | ||
|
||
export function three() { | ||
type Z = string; | ||
return {} as Z; | ||
} | ||
//// [variables.js] //// | ||
const x = ""; | ||
export function one() { | ||
return {}; | ||
} | ||
export function two() { | ||
const y = ""; | ||
return {}; | ||
} | ||
export function three() { | ||
return {}; | ||
} |
48 changes: 48 additions & 0 deletions
48
tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports49-private-name.ts
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,48 @@ | ||
/// <reference path='fourslash.ts'/> | ||
|
||
// @isolatedDeclarations: true | ||
// @declaration: true | ||
// @moduleResolution: node | ||
// @target: es2018 | ||
// @jsx: react-jsx | ||
|
||
////export function two() { | ||
//// const y = ""; | ||
//// return {} as typeof y; | ||
////} | ||
//// | ||
////export function three() { | ||
//// type Z = string; | ||
//// return {} as Z; | ||
////} | ||
|
||
verify.codeFix({ | ||
description: "Add return type '\"\"'", | ||
index: 0, | ||
newFileContent: | ||
`export function two(): "" { | ||
const y = ""; | ||
return {} as typeof y; | ||
} | ||
export function three() { | ||
type Z = string; | ||
return {} as Z; | ||
}`, | ||
}); | ||
|
||
|
||
verify.codeFix({ | ||
description: "Add return type 'string'", | ||
index: 1, | ||
newFileContent: | ||
`export function two() { | ||
const y = ""; | ||
return {} as typeof y; | ||
} | ||
export function three(): string { | ||
type Z = string; | ||
return {} as Z; | ||
}`, | ||
}); |
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,17 @@ | ||
// @declaration: true | ||
// @target: es6 | ||
// @filename: variables.ts | ||
const x = ""; | ||
export function one() { | ||
return {} as typeof x; | ||
} | ||
|
||
export function two() { | ||
const y = ""; | ||
return {} as typeof y; | ||
} | ||
|
||
export function three() { | ||
type Z = string; | ||
return {} as Z; | ||
} |