Commit 3e84e1c
feat: generate .d.ts Ivy type declarations for Angular library builds (#101)
* feat: generate .d.ts Ivy type declarations for Angular library builds
Add `dts_declarations` field to `TransformResult` that generates the static
type declarations (ɵfac, ɵcmp, ɵdir, ɵpipe, ɵmod, ɵinj, ɵprov) needed in
`.d.ts` files for Angular library consumers to perform template type-checking.
This enables build tools like tsdown to post-process `.d.ts` output and inject
Ivy declarations, solving the "Component imports must be standalone" error when
publishing Angular libraries compiled with Oxc.
Supports all Angular decorator types: @component, @directive, @pipe, @NgModule,
and @Injectable, including input/output maps, signal inputs, exportAs, host
directives, and constructor @Attribute() dependencies.
- Close #86
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: align .d.ts declarations with Angular TS compiler
- Fix factory CtorDeps to emit object literal types with attribute/optional/host/self/skipSelf
- Emit `null` instead of `""` for pipe names when not specified
- Add type_argument_count support for generic Injectable/Pipe/NgModule
- Handle control character escaping (\n, \r, \t) in dts strings
- Surface ng-content selectors from template compilation pipeline
- Generate ngAcceptInputType_* fields for inputs with transforms
- Add comprehensive tests for all dts generation scenarios
Fix #86
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* refactor: improve host directive name extraction and deduplicate ctor deps
- Handle ReadProp (namespace-qualified, e.g. i1.SomeDirective) and
External expression variants in extract_directive_name_from_expr
- Replace silent "unknown" fallback with descriptive panic for
unhandled variants
- Extract shared ctor deps formatting logic into generate_ctor_deps_type
helper, reducing ~80 lines of duplication
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: populate directive type_argument_count and eliminate duplicate extract_injectable_metadata calls
- Set type_argument_count on directive metadata from class.type_parameters,
matching how Component/Pipe/NgModule/Injectable already do it.
Without this, generic directives like `MyDirective<T>` emit `MyDirective`
instead of `MyDirective<any>` in .d.ts declarations.
- Eliminate 4 redundant extract_injectable_metadata calls (one per decorator
branch) by capturing the result of the first call and deriving the boolean.
- Add test for generic directive dts output.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent c380a55 commit 3e84e1c
File tree
6 files changed
+1821
-15
lines changed- crates/oxc_angular_compiler
- src
- component
- tests
- napi/angular-compiler
- src
6 files changed
+1821
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| |||
276 | 277 | | |
277 | 278 | | |
278 | 279 | | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
279 | 294 | | |
280 | 295 | | |
281 | 296 | | |
| |||
1565 | 1580 | | |
1566 | 1581 | | |
1567 | 1582 | | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
1568 | 1588 | | |
1569 | 1589 | | |
1570 | 1590 | | |
| |||
1617 | 1637 | | |
1618 | 1638 | | |
1619 | 1639 | | |
1620 | | - | |
1621 | | - | |
1622 | | - | |
| 1640 | + | |
| 1641 | + | |
1623 | 1642 | | |
1624 | 1643 | | |
1625 | 1644 | | |
1626 | 1645 | | |
1627 | 1646 | | |
1628 | | - | |
| 1647 | + | |
1629 | 1648 | | |
1630 | 1649 | | |
1631 | 1650 | | |
| |||
1634 | 1653 | | |
1635 | 1654 | | |
1636 | 1655 | | |
| 1656 | + | |
1637 | 1657 | | |
1638 | 1658 | | |
1639 | 1659 | | |
| |||
1736 | 1756 | | |
1737 | 1757 | | |
1738 | 1758 | | |
| 1759 | + | |
| 1760 | + | |
| 1761 | + | |
| 1762 | + | |
| 1763 | + | |
| 1764 | + | |
| 1765 | + | |
| 1766 | + | |
| 1767 | + | |
| 1768 | + | |
| 1769 | + | |
| 1770 | + | |
| 1771 | + | |
1739 | 1772 | | |
1740 | 1773 | | |
1741 | 1774 | | |
| |||
1814 | 1847 | | |
1815 | 1848 | | |
1816 | 1849 | | |
1817 | | - | |
1818 | | - | |
| 1850 | + | |
| 1851 | + | |
1819 | 1852 | | |
1820 | 1853 | | |
1821 | 1854 | | |
1822 | 1855 | | |
1823 | 1856 | | |
1824 | | - | |
| 1857 | + | |
1825 | 1858 | | |
1826 | 1859 | | |
1827 | 1860 | | |
1828 | 1861 | | |
1829 | 1862 | | |
1830 | 1863 | | |
1831 | 1864 | | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
| 1870 | + | |
| 1871 | + | |
| 1872 | + | |
| 1873 | + | |
1832 | 1874 | | |
1833 | 1875 | | |
1834 | 1876 | | |
| |||
1879 | 1921 | | |
1880 | 1922 | | |
1881 | 1923 | | |
1882 | | - | |
1883 | | - | |
1884 | | - | |
| 1924 | + | |
| 1925 | + | |
1885 | 1926 | | |
1886 | 1927 | | |
1887 | 1928 | | |
1888 | 1929 | | |
1889 | 1930 | | |
1890 | | - | |
| 1931 | + | |
1891 | 1932 | | |
1892 | 1933 | | |
1893 | 1934 | | |
1894 | 1935 | | |
1895 | 1936 | | |
1896 | 1937 | | |
1897 | 1938 | | |
| 1939 | + | |
| 1940 | + | |
| 1941 | + | |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
| 1946 | + | |
| 1947 | + | |
| 1948 | + | |
1898 | 1949 | | |
1899 | 1950 | | |
1900 | 1951 | | |
| |||
1951 | 2002 | | |
1952 | 2003 | | |
1953 | 2004 | | |
1954 | | - | |
1955 | | - | |
1956 | | - | |
| 2005 | + | |
| 2006 | + | |
1957 | 2007 | | |
1958 | 2008 | | |
1959 | 2009 | | |
1960 | 2010 | | |
1961 | 2011 | | |
1962 | | - | |
| 2012 | + | |
1963 | 2013 | | |
1964 | 2014 | | |
1965 | 2015 | | |
1966 | 2016 | | |
1967 | 2017 | | |
1968 | 2018 | | |
1969 | 2019 | | |
| 2020 | + | |
1970 | 2021 | | |
1971 | 2022 | | |
1972 | 2023 | | |
| |||
1977 | 2028 | | |
1978 | 2029 | | |
1979 | 2030 | | |
| 2031 | + | |
| 2032 | + | |
| 2033 | + | |
| 2034 | + | |
| 2035 | + | |
| 2036 | + | |
| 2037 | + | |
| 2038 | + | |
| 2039 | + | |
1980 | 2040 | | |
1981 | 2041 | | |
1982 | 2042 | | |
| |||
2028 | 2088 | | |
2029 | 2089 | | |
2030 | 2090 | | |
| 2091 | + | |
| 2092 | + | |
| 2093 | + | |
| 2094 | + | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
| 2098 | + | |
2031 | 2099 | | |
2032 | 2100 | | |
2033 | 2101 | | |
| |||
2172 | 2240 | | |
2173 | 2241 | | |
2174 | 2242 | | |
| 2243 | + | |
| 2244 | + | |
| 2245 | + | |
2175 | 2246 | | |
2176 | 2247 | | |
2177 | 2248 | | |
| |||
2246 | 2317 | | |
2247 | 2318 | | |
2248 | 2319 | | |
| 2320 | + | |
| 2321 | + | |
| 2322 | + | |
| 2323 | + | |
2249 | 2324 | | |
2250 | 2325 | | |
2251 | 2326 | | |
| |||
2486 | 2561 | | |
2487 | 2562 | | |
2488 | 2563 | | |
| 2564 | + | |
2489 | 2565 | | |
2490 | 2566 | | |
2491 | 2567 | | |
| |||
0 commit comments