Skip to content

Commit

Permalink
Merge pull request #380 from NullVoxPopuli/add-types-from-dt
Browse files Browse the repository at this point in the history
Ship own types (copy from DT)
  • Loading branch information
chriskrycho committed May 15, 2023
2 parents f10cf74 + 0125775 commit b1ffc56
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 6 deletions.
28 changes: 27 additions & 1 deletion .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,32 @@ 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.9'
- '~5.0'
- 'beta'
steps:
- uses: actions/checkout@v2
- uses: volta-cli/action@v1
with:
# TS 5.1 does not support node 12
node-version: 14.x
- name: install dependencies
run: yarn install --frozen-lockfile
- name: Swap TS Version
run: yarn add --dev typescript@${{ matrix.tsVersion }}
- name: Check Types
run: |
yarn tsc -v
yarn test:types
try-scenarios:
name: "Try: ${{ matrix.ember-try-scenario }}"

Expand Down Expand Up @@ -89,4 +115,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[];
5 changes: 4 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 @@ -76,6 +78,7 @@
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-qunit": "^7.3.4",
"expect-type": "^0.15.0",
"loader.js": "^4.7.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.6.0",
Expand All @@ -84,7 +87,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",
"webpack": "^5"
},
"engines": {
Expand Down
60 changes: 60 additions & 0 deletions type-tests/the-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import {
dasherize,
camelize,
capitalize,
classify,
decamelize,
underscore,
w,
} from '@ember/string';

import { expectTypeOf } from 'expect-type';

// @ts-expect-error
dasherize();
// @ts-expect-error
dasherize('', '');

expectTypeOf(dasherize('blue man group')).toBeString();

// @ts-expect-error
camelize();
// @ts-expect-error
camelize('', '');

expectTypeOf(camelize('blue man group')).toBeString();

// @ts-expect-error
decamelize();
// @ts-expect-error
decamelize('', '');

expectTypeOf(decamelize('blue man group')).toBeString();

// @ts-expect-error
underscore();
// @ts-expect-error
underscore('', '');

expectTypeOf(underscore('blue man group')).toBeString();

// @ts-expect-error
w();
// @ts-expect-error
w('', '');

expectTypeOf(w('blue man group')).toMatchTypeOf<string[]>();

// @ts-expect-error
classify();
// @ts-expect-error
classify('', '');

expectTypeOf(classify('blue man group')).toBeString();

// @ts-expect-error
capitalize();
// @ts-expect-error
capitalize('', '');

expectTypeOf(capitalize('blue man group')).toBeString();
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": ["../"]
}
}
}
18 changes: 14 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 @@ -6360,6 +6365,11 @@ expand-tilde@^2.0.0, expand-tilde@^2.0.2:
dependencies:
homedir-polyfill "^1.0.1"

expect-type@^0.15.0:
version "0.15.0"
resolved "https://registry.yarnpkg.com/expect-type/-/expect-type-0.15.0.tgz#89f75e22c88554844ea2b2faf4ef5fc2e579d3b5"
integrity sha512-yWnriYB4e8G54M5/fAFj7rCIBiKs1HAACaY13kCz6Ku0dezjS9aMcfcdVK2X8Tv2tEV1BPz/wKfQ7WA4S/d8aA==

express@^4.10.7, express@^4.17.1:
version "4.18.2"
resolved "https://registry.yarnpkg.com/express/-/express-4.18.2.tgz#3fabe08296e930c796c19e3c516979386ba9fd59"
Expand Down Expand Up @@ -12499,10 +12509,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

0 comments on commit b1ffc56

Please sign in to comment.