Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions types/ember/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import { TemplateFactory } from 'htmlbars-inline-precompile';
import { Registry as ServiceRegistry } from '@ember/service';
import { Registry as ControllerRegistry } from '@ember/controller';
import * as EmberStringNs from '@ember/string';
import * as EmberTemplateNs from '@ember/template';
import * as EmberTemplateHandlebarsNs from '@ember/template/-private/handlebars';
// tslint:disable-next-line:no-duplicate-imports
import * as EmberServiceNs from '@ember/service';
Expand Down Expand Up @@ -443,12 +444,16 @@ export namespace Ember {
const dasherize: typeof EmberStringNs.dasherize;
const decamelize: typeof EmberStringNs.decamelize;
function fmt(...args: string[]): string;
const htmlSafe: typeof EmberStringNs.htmlSafe;
const isHTMLSafe: typeof EmberStringNs.isHTMLSafe;
const htmlSafe: typeof EmberTemplateNs.htmlSafe;
const isHTMLSafe: typeof EmberTemplateNs.isHTMLSafe;
const loc: typeof EmberStringNs.loc;
const underscore: typeof EmberStringNs.underscore;
const w: typeof EmberStringNs.w;
}
namespace Template {
const htmlSafe: typeof EmberTemplateNs.htmlSafe;
const isHTMLSafe: typeof EmberTemplateNs.isHTMLSafe;
}
const computed: typeof EmberObjectNs.computed;
const run: typeof EmberRunloopNs.run;
const platform: {
Expand All @@ -473,6 +478,9 @@ export namespace Ember {
const sendEvent: typeof EmberObjectEventsNs.sendEvent;
const on: typeof EmberObjectEventedNs.on;

const htmlSafe: typeof EmberTemplateNs.htmlSafe;
const isHTMLSafe: typeof EmberTemplateNs.isHTMLSafe;

const isBlank: typeof EmberUtilsNs.isBlank;
const isEmpty: typeof EmberUtilsNs.isEmpty;
const isNone: typeof EmberUtilsNs.isNone;
Expand Down
2 changes: 0 additions & 2 deletions types/ember__string/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.7

export { htmlSafe, isHTMLSafe } from '@ember/template';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure removing this re-export was actually the right thing. See discussions in: #38571

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gah, I had a vague memory there was something like that but when I went poking around I couldn’t find it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can’t actually find either any public documentation of the @ember/string exports or deprecations thereof, but I believe the issue that spawned this PR was due to @ember/string’s incorrectly publishing types, so presumably they are public? This seems to be a bit of a mess. 😬

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a mess. The@ember/string package is written in TS and does indeed ship types (that don't include htmlSafe and isHTMLSafe because they are not implemented there), but that package is an addon of string utilities extracted from Ember. ember-source also provides @ember/string, which does include htmlSafe and isHTMLSafe as demonstrated in this twiddle (they are added to @ember/string here in ember-source, where htmlSafe is defined here and isHTMLSafe is defined here). The @ember/string package is not a dep of ember-source, but is is a dep of ember-data as of 3.24: warp-drive-data/warp-drive#7356. Twiddle only goes up to 3.18, so I tried the same thing I did there locally with a fresh 3.24 app and it still works (is functional) but fails to typecheck. Just downgrading to @types/[email protected] does not work in this case because [email protected] has installed the @ember/string package and TS is using it's types rather than @types/ember__string. If I remove ember-data (and thus the @ember/string package) with the downgraded @types/ember__string, it typechecks (and is functional). A solution that does work for both cases, however, is using module augmentation here instead of module declaration. I'll open a PR shortly for this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, wait found more info!: emberjs/rfc-tracking#26
IMHO we should leave these in until removed (which I assume won't be until Ember 4.0).


export function camelize(str: string): string;
export function capitalize(str: string): string;
export function classify(str: string): string;
Expand Down