Skip to content
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

Ship own types (copy from DT) #380

Merged
merged 10 commits into from
May 15, 2023
27 changes: 26 additions & 1 deletion .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,31 @@ jobs:
- run: yarn install --no-lockfile
- run: yarn test:ember

types-scenarios:
name: "Types: ${{ matrix.tsVersion }}"
runs-on: ubuntu-latest
needs: test

strategy:
matrix:
tsVersion:
- 4.4
- 4.6
- 4.8
- 5.0
- 5.1
NullVoxPopuli marked this conversation as resolved.
Show resolved Hide resolved
steps:
- uses: actions/checkout@v2
- uses: volta-cli/action@v1
- name: install dependencies
run: yarn install --frozen-lockfile
- name: Swap TS Version
run: yarn add --dev typescript@{{ matrix.tsVersion }}
- name: Check Types
run: |
tsc -v
yarn test:types

try-scenarios:
name: "Try: ${{ matrix.ember-try-scenario }}"

Expand Down Expand Up @@ -89,4 +114,4 @@ jobs:
- name: publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
7 changes: 7 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export function camelize(str: string): string;
export function capitalize(str: string): string;
export function classify(str: string): string;
export function dasherize(str: string): string;
export function decamelize(str: string): string;
export function underscore(str: string): string;
export function w(str: string): string[];
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"start": "ember serve",
"test": "npm-run-all lint test:*",
"test:ember": "ember test",
"test:types": "tsc --noEmit --project ./type-tests/tsconfig.json",
"test:ember-compatibility": "ember try:each",
"test-typings": "node node_modules/typescript/bin/tsc",
"prepack": "yarn babel --extensions '.ts' --presets @babel/preset-typescript addon --out-dir addon/ --ignore '**/*.d.ts'",
Expand All @@ -42,6 +43,7 @@
"@embroider/test-setup": "^0.47.1",
"@glimmer/component": "^1.0.4",
"@glimmer/tracking": "^1.0.4",
"@tsconfig/ember": "^2.0.0",
"@types/ember": "^3.16.5",
"@types/ember-qunit": "^3.4.14",
"@types/ember__test-helpers": "^2.0.2",
Expand Down Expand Up @@ -84,7 +86,7 @@
"release-it": "^14.11.6",
"release-it-lerna-changelog": "^3.1.0",
"rimraf": "^3.0.2",
"typescript": "^4.4.4",
"typescript": "^5.0.4",
Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

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

looks like this didn't change -- I didn't even check if this project already had TS available 😅

"webpack": "^5"
},
"engines": {
Expand Down
51 changes: 51 additions & 0 deletions type-tests/the-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import {
dasherize,
camelize,
capitalize,
classify,
decamelize,
underscore,
w,
} from '@ember/string';

// @ts-expect-error
dasherize();
dasherize('blue man group'); // $ExpectType string
NullVoxPopuli marked this conversation as resolved.
Show resolved Hide resolved
// @ts-expect-error
dasherize('', '');

// @ts-expect-error
camelize();
camelize('blue man group'); // $ExpectType string
// @ts-expect-error
camelize('', '');

// @ts-expect-error
decamelize();
decamelize('blue man group'); // $ExpectType string
// @ts-expect-error
decamelize('', '');

// @ts-expect-error
underscore();
underscore('blue man group'); // $ExpectType string
// @ts-expect-error
underscore('', '');

// @ts-expect-error
w();
w('blue man group'); // $ExpectType string[]
// @ts-expect-error
w('', '');

// @ts-expect-error
classify();
classify('blue man group'); // $ExpectType string
// @ts-expect-error
classify('', '');

// @ts-expect-error
capitalize();
capitalize('blue man group'); // $ExpectType string
// @ts-expect-error
capitalize('', '');
8 changes: 8 additions & 0 deletions type-tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "@tsconfig/ember",
"compilerOptions": {
"paths": {
"@ember/string": ["../"]
}
}
}
13 changes: 9 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1774,6 +1774,11 @@
resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82"
integrity sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==

"@tsconfig/ember@^2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@tsconfig/ember/-/ember-2.0.0.tgz#dba953e5527ccf7a2587f262a7afe0fa83c4e979"
integrity sha512-RzbDYYcjxVdG8Ki0xe99HN3+nHTZe6EBgw6N7B3yup7QogVFQQxA9nY7X80j1XzF15xqetwWiYfAjv5lkkp0/A==

"@types/body-parser@*":
version "1.19.1"
resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.19.1.tgz#0c0174c42a7d017b818303d4b5d969cb0b75929c"
Expand Down Expand Up @@ -12499,10 +12504,10 @@ typescript-memoize@^1.0.0-alpha.3:
resolved "https://registry.yarnpkg.com/typescript-memoize/-/typescript-memoize-1.0.1.tgz#0a8199aa28f6fe18517f6e9308ef7bfbe9a98d59"
integrity sha512-oJNge1qUrOK37d5Y6Ly2txKeuelYVsFtNF6U9kXIN7juudcQaHJQg2MxLOy0CqtkW65rVDYuTCOjnSIVPd8z3w==

typescript@^4.4.4:
version "4.4.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.4.tgz#2cd01a1a1f160704d3101fd5a58ff0f9fcb8030c"
integrity sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==
typescript@^5.0.4:
version "5.0.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.0.4.tgz#b217fd20119bd61a94d4011274e0ab369058da3b"
integrity sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==

uc.micro@^1.0.1, uc.micro@^1.0.5:
version "1.0.6"
Expand Down