-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Dont use baseURL relative absolute paths in declaration emit, use absolute paths in bundle emit #26341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
weswigham
merged 2 commits into
microsoft:master
from
weswigham:prefer-relative-declaration-paths
Aug 10, 2018
Merged
Dont use baseURL relative absolute paths in declaration emit, use absolute paths in bundle emit #26341
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
50 changes: 50 additions & 0 deletions
50
tests/baselines/reference/declarationEmitPrefersPathKindBasedOnBundling.js
This file contains hidden or 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,50 @@ | ||
//// [tests/cases/compiler/declarationEmitPrefersPathKindBasedOnBundling.ts] //// | ||
|
||
//// [scalar.ts] | ||
export interface Scalar { | ||
(): string; | ||
value: number; | ||
} | ||
|
||
export function scalar(value: string): Scalar { | ||
return null as any; | ||
} | ||
//// [spacing.ts] | ||
import { scalar } from '../lib/operators/scalar'; | ||
|
||
export default { | ||
get xs() { | ||
return scalar("14px"); | ||
} | ||
}; | ||
|
||
|
||
//// [scalar.js] | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function scalar(value) { | ||
return null; | ||
} | ||
exports.scalar = scalar; | ||
//// [spacing.js] | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var scalar_1 = require("../lib/operators/scalar"); | ||
exports.default = { | ||
get xs() { | ||
return scalar_1.scalar("14px"); | ||
} | ||
}; | ||
|
||
|
||
//// [scalar.d.ts] | ||
export interface Scalar { | ||
(): string; | ||
value: number; | ||
} | ||
export declare function scalar(value: string): Scalar; | ||
//// [spacing.d.ts] | ||
declare const _default: { | ||
readonly xs: import("../lib/operators/scalar").Scalar; | ||
}; | ||
export default _default; |
29 changes: 29 additions & 0 deletions
29
tests/baselines/reference/declarationEmitPrefersPathKindBasedOnBundling.symbols
This file contains hidden or 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,29 @@ | ||
=== tests/cases/compiler/src/lib/operators/scalar.ts === | ||
export interface Scalar { | ||
>Scalar : Symbol(Scalar, Decl(scalar.ts, 0, 0)) | ||
|
||
(): string; | ||
value: number; | ||
>value : Symbol(Scalar.value, Decl(scalar.ts, 1, 12)) | ||
} | ||
|
||
export function scalar(value: string): Scalar { | ||
>scalar : Symbol(scalar, Decl(scalar.ts, 3, 1)) | ||
>value : Symbol(value, Decl(scalar.ts, 5, 23)) | ||
>Scalar : Symbol(Scalar, Decl(scalar.ts, 0, 0)) | ||
|
||
return null as any; | ||
} | ||
=== tests/cases/compiler/src/settings/spacing.ts === | ||
import { scalar } from '../lib/operators/scalar'; | ||
>scalar : Symbol(scalar, Decl(spacing.ts, 0, 8)) | ||
|
||
export default { | ||
get xs() { | ||
>xs : Symbol(xs, Decl(spacing.ts, 2, 16)) | ||
|
||
return scalar("14px"); | ||
>scalar : Symbol(scalar, Decl(spacing.ts, 0, 8)) | ||
} | ||
}; | ||
|
32 changes: 32 additions & 0 deletions
32
tests/baselines/reference/declarationEmitPrefersPathKindBasedOnBundling.types
This file contains hidden or 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,32 @@ | ||
=== tests/cases/compiler/src/lib/operators/scalar.ts === | ||
export interface Scalar { | ||
(): string; | ||
value: number; | ||
>value : number | ||
} | ||
|
||
export function scalar(value: string): Scalar { | ||
>scalar : (value: string) => Scalar | ||
>value : string | ||
|
||
return null as any; | ||
>null as any : any | ||
>null : null | ||
} | ||
=== tests/cases/compiler/src/settings/spacing.ts === | ||
import { scalar } from '../lib/operators/scalar'; | ||
>scalar : (value: string) => import("tests/cases/compiler/src/lib/operators/scalar").Scalar | ||
|
||
export default { | ||
>{ get xs() { return scalar("14px"); }} : { readonly xs: import("tests/cases/compiler/src/lib/operators/scalar").Scalar; } | ||
|
||
get xs() { | ||
>xs : import("tests/cases/compiler/src/lib/operators/scalar").Scalar | ||
|
||
return scalar("14px"); | ||
>scalar("14px") : import("tests/cases/compiler/src/lib/operators/scalar").Scalar | ||
>scalar : (value: string) => import("tests/cases/compiler/src/lib/operators/scalar").Scalar | ||
>"14px" : "14px" | ||
} | ||
}; | ||
|
55 changes: 55 additions & 0 deletions
55
tests/baselines/reference/declarationEmitPrefersPathKindBasedOnBundling2.js
This file contains hidden or 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,55 @@ | ||
//// [tests/cases/compiler/declarationEmitPrefersPathKindBasedOnBundling2.ts] //// | ||
|
||
//// [scalar.ts] | ||
export interface Scalar { | ||
(): string; | ||
value: number; | ||
} | ||
|
||
export function scalar(value: string): Scalar { | ||
return null as any; | ||
} | ||
//// [spacing.ts] | ||
import { scalar } from '../lib/operators/scalar'; | ||
|
||
export default { | ||
get xs() { | ||
return scalar("14px"); | ||
} | ||
}; | ||
|
||
|
||
//// [dist.js] | ||
define("lib/operators/scalar", ["require", "exports"], function (require, exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function scalar(value) { | ||
return null; | ||
} | ||
exports.scalar = scalar; | ||
}); | ||
define("settings/spacing", ["require", "exports", "lib/operators/scalar"], function (require, exports, scalar_1) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = { | ||
get xs() { | ||
return scalar_1.scalar("14px"); | ||
} | ||
}; | ||
}); | ||
|
||
|
||
//// [dist.d.ts] | ||
declare module "lib/operators/scalar" { | ||
export interface Scalar { | ||
(): string; | ||
value: number; | ||
} | ||
export function scalar(value: string): Scalar; | ||
} | ||
declare module "settings/spacing" { | ||
const _default: { | ||
readonly xs: import("lib/operators/scalar").Scalar; | ||
}; | ||
export default _default; | ||
} |
29 changes: 29 additions & 0 deletions
29
tests/baselines/reference/declarationEmitPrefersPathKindBasedOnBundling2.symbols
This file contains hidden or 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,29 @@ | ||
=== tests/cases/compiler/src/lib/operators/scalar.ts === | ||
export interface Scalar { | ||
>Scalar : Symbol(Scalar, Decl(scalar.ts, 0, 0)) | ||
|
||
(): string; | ||
value: number; | ||
>value : Symbol(Scalar.value, Decl(scalar.ts, 1, 12)) | ||
} | ||
|
||
export function scalar(value: string): Scalar { | ||
>scalar : Symbol(scalar, Decl(scalar.ts, 3, 1)) | ||
>value : Symbol(value, Decl(scalar.ts, 5, 23)) | ||
>Scalar : Symbol(Scalar, Decl(scalar.ts, 0, 0)) | ||
|
||
return null as any; | ||
} | ||
=== tests/cases/compiler/src/settings/spacing.ts === | ||
import { scalar } from '../lib/operators/scalar'; | ||
>scalar : Symbol(scalar, Decl(spacing.ts, 0, 8)) | ||
|
||
export default { | ||
get xs() { | ||
>xs : Symbol(xs, Decl(spacing.ts, 2, 16)) | ||
|
||
return scalar("14px"); | ||
>scalar : Symbol(scalar, Decl(spacing.ts, 0, 8)) | ||
} | ||
}; | ||
|
32 changes: 32 additions & 0 deletions
32
tests/baselines/reference/declarationEmitPrefersPathKindBasedOnBundling2.types
This file contains hidden or 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,32 @@ | ||
=== tests/cases/compiler/src/lib/operators/scalar.ts === | ||
export interface Scalar { | ||
(): string; | ||
value: number; | ||
>value : number | ||
} | ||
|
||
export function scalar(value: string): Scalar { | ||
>scalar : (value: string) => Scalar | ||
>value : string | ||
|
||
return null as any; | ||
>null as any : any | ||
>null : null | ||
} | ||
=== tests/cases/compiler/src/settings/spacing.ts === | ||
import { scalar } from '../lib/operators/scalar'; | ||
>scalar : (value: string) => import("tests/cases/compiler/src/lib/operators/scalar").Scalar | ||
|
||
export default { | ||
>{ get xs() { return scalar("14px"); }} : { readonly xs: import("tests/cases/compiler/src/lib/operators/scalar").Scalar; } | ||
|
||
get xs() { | ||
>xs : import("tests/cases/compiler/src/lib/operators/scalar").Scalar | ||
|
||
return scalar("14px"); | ||
>scalar("14px") : import("tests/cases/compiler/src/lib/operators/scalar").Scalar | ||
>scalar : (value: string) => import("tests/cases/compiler/src/lib/operators/scalar").Scalar | ||
>"14px" : "14px" | ||
} | ||
}; | ||
|
22 changes: 22 additions & 0 deletions
22
tests/cases/compiler/declarationEmitPrefersPathKindBasedOnBundling.ts
This file contains hidden or 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,22 @@ | ||
// @declaration: true | ||
// @target: es5 | ||
// @baseUrl: /.src/tests/cases/compiler | ||
// @outDir: ./dist | ||
// @rootDir: ./tests/cases/compiler/src | ||
// @filename: src/lib/operators/scalar.ts | ||
export interface Scalar { | ||
(): string; | ||
value: number; | ||
} | ||
|
||
export function scalar(value: string): Scalar { | ||
return null as any; | ||
} | ||
// @filename: src/settings/spacing.ts | ||
import { scalar } from '../lib/operators/scalar'; | ||
|
||
export default { | ||
get xs() { | ||
return scalar("14px"); | ||
} | ||
}; |
23 changes: 23 additions & 0 deletions
23
tests/cases/compiler/declarationEmitPrefersPathKindBasedOnBundling2.ts
This file contains hidden or 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,23 @@ | ||
// @declaration: true | ||
// @target: es5 | ||
// @baseUrl: /.src/tests/cases/compiler | ||
// @module: amd | ||
// @outFile: ./dist.js | ||
// @rootDir: ./tests/cases/compiler/src | ||
// @filename: src/lib/operators/scalar.ts | ||
export interface Scalar { | ||
(): string; | ||
value: number; | ||
} | ||
|
||
export function scalar(value: string): Scalar { | ||
return null as any; | ||
} | ||
// @filename: src/settings/spacing.ts | ||
import { scalar } from '../lib/operators/scalar'; | ||
|
||
export default { | ||
get xs() { | ||
return scalar("14px"); | ||
} | ||
}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the API would be better if this and
getCommonSourceDirectory
weren't optional members of this interface, and were just passed in as values in the one place they're needed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmmmm they're on the interface because that interface is how the declaration emitter shuffles bits of its emit host into the checker to fulfill these needs. And I don't particularly want to pass in a second host object with the kinda-nice-to-have-for-one-of-the-entry-points methods (especially since
{moduleResolverHost: host, declarationModuleResolverHost: host}
indeclarations.ts
would look like we were going mad).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't mean to add a second host for those methods, but that a host isn't necessary at all. Both methods are immediately called in the first function and not used by anything else in
moduleSpecifiers
.Making the method optional seems to cover up problems, such as the fact that
getCommonSourceDirectory
isn't defined onTypeCheckerHost
(although it might happen to be defined at runtime anyway, though possibly with a different type), and users of other functions will think they need to provide these methods even when they're unused outside ofgetModuleSpecifierForDeclarationFile
. It also looks likehost.getSourceFiles()
is non-optional so testing for its existence is dead code.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A host is merely a group of argument methods to delegate to, no? If I need two, it's reasonable to group them into a second host object.